/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: zhongyisheng
 * Date: 2024-07-08
 * Time: 14:40
 */
public class Test {
    @Override
    public void display() {
        ListNode cur = head;

        while (cur!=null){
            System.out.print(cur.val);
            cur = cur.next;
        }

    }
    @Override
    public int size() {
        ListNode cur = head;
        int count = 0;
        while (cur!=null){
            count++;
            cur = cur.next;
        }
        return count;
    }
    @Override
    public boolean contains(int key) {
        ListNode cur = head;
        int count = 0;
        while (cur!=null){
            if(cur.val == key)
                return true;
        }
        return false;
    }
    public void addIndex(int index, int data) {
        int len = size();
        if(index < 0 || index > len) {
            return;
        }
        if(index == 0) {
            addFirst(data);
            return;
        }
        if(index == len) {
            addLast(data);
            return;
        }
        int count = 0;
        ListNode node = new ListNode(data);
        while(count != index){
            cur = cur.next;
            count++;
        }
        cur.prev


    }

    public static void main(String[] args) {

    }
}
